<?php

require_once(ABSPATH . '/MiiLib/Cmn.php');

// using
use \hpnWse\nWp\stBase as stWpBase;

$l_Uid = null;
if (\hpnApp\fIsMember())
{
	$l_Uid = $_SESSION['UserProfile']['Id'];
}

global $post;

$l_Qmeta = \hpnApp\fFchQstnMeta($post->ID);
$l_Aprs = $l_Uid ? \hpnApp\fFchUserAprsForQstn($l_Uid, $post->ID) : 0;
$l_Like = $l_Uid ? \hpnApp\fFchUserLikeForQstn($l_Uid, $post->ID) : false;

?>

<?php get_header(); ?>

<!-- 呈现目标 -->
<div id="k_PrstTgt" class="mi_Single">
</div>

<!-- 呈现来源 -->
<div id="k_PrstSrc">

<div id="k_RootPutSrc" class="cnWse_PutSrc"
	data-wse_use_prst_tgt="true"
>
	<?php \hpnApp\fIcldFgmtTmp('NavBar.php') ?>

	<div class="mi_CenPut cnWse_ClearFix">
		<div class="mi_MainDiv">
			<h1><?php echo $post->post_title; ?></h1>


			<div class="mi_Qstn">
				<article><?php echo $post->post_content; ?></article>

				<div class="mi_Imgs">
					<?php foreach ($l_Qmeta['Imgs'] as $l_Idx => $l_Url) : ?>
					<span class="mi_ImgWrap" data-wse_cmd="bigimg <?php echo $l_Idx ?>"><img src="<?php echo $l_Url ?>" /></span>
					<?php endforeach ?>
				</div>

				<div class="cnWse_PutSrc" data-wse_bld_wgt="tMdlView"
					data-wse_bind_mdl="Qstn"
				>
					<div data-wse_tmp_html="true" class="mi_Cmts">
						<span class="mi_Pstv" data-wse_cmd="inc_pn Pstv" data-wse_bind_fld="Aprs" data-wse_bind_attr="" data-wse_bind_attr_only="true"><i class="fa fa-thumbs-up"></i><span data-wse_bind_fld="Pstv"></span> 赞</span>
						<span class="mi_Ngtv" data-wse_cmd="inc_pn Ngtv" data-wse_bind_fld="Aprs" data-wse_bind_attr="" data-wse_bind_attr_only="true"><i class="fa fa-thumbs-down"></i><span data-wse_bind_fld="Ngtv"></span> 踩</span>
						<span><i class="fa fa-commenting"></i><?php echo $post->comment_count ?> 回答</span>
						<span class="mi_Like" data-wse_cmd="like" data-wse_bind_fld="Like" data-wse_bind_attr="" data-wse_bind_attr_only="true"><i class="fa fa-heart"></i><span data-wse_bind_fld="Fav"></span> 收藏</span>
					</div>
				</div>
			</div>
			
		</div>

		<div class="mi_SideDiv">
			<?php \hpnApp\fIcldFgmtTmp('SideBar.php') ?>
		</div>
	</div>
</div>

</div>

<script type="text/javascript">
	<?php
	echo 'window.g_PageData = {' . PHP_EOL;
		echo 'Qid: ' . $post->ID . ',' . PHP_EOL;
		echo 'Meta: ' . \hpnWse\stObjUtil::cEcdJson($l_Qmeta) . ',' . PHP_EOL;
		echo 'Aprs: ' . $l_Aprs . ',' . PHP_EOL;
		echo 'Like: ' . ($l_Like ? 1 : 0) . ',' . PHP_EOL;
	echo '};';
	?>
</script>

<script type="text/javascript" src="<?php echo site_url() . '/js/Cmn.js' ?>"></script>
<script type="text/javascript" src="<?php echo site_url() . '/js/single.js' ?>"></script>

<?php get_footer(); ?>
